package com.yuerlive.rainbow.common;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;

import com.yuerlive.rainbow.base.BaseActivity;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by xiaoyi on 2017/6/19.
 */

public class ActivityStack {
    private static LinkedList<Activity> mActivities = new LinkedList<>();

    public static void add(Activity activity) {
        mActivities.add(activity);
    }

    public static void remove(Activity activity) {
        mActivities.remove(activity);
    }

    public static void removeAll() {
        for (Activity activity : mActivities) {
            mActivities.remove(activity);
            activity.finish();
        }
    }

    public static BaseActivity getTopActivity() {
        if (mActivities.isEmpty()) return null;
        return (BaseActivity) mActivities.get(mActivities.size() - 1);
    }

}
